package com.cat.dataStructure03;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/node-with-highest-edge-score/
 * @create 2025/11/16 14:40
 * @since JDK17
 */

public class Solution69 {
    public int edgeScore(int[] edges) {
        int n = edges.length, max = 0;
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[edges[i]] += i;
        }
        for (int i = 0; i < n; i++) {
            if (arr[max] < arr[i]) {
                max = i;
            }
        }

        return max;
    }
}
